package com.manuserve.mountainduck.kernel;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;



/**
 * Gere un sprite
 * Created by xmanoux on 09/03/14.
 */
public class Sprite {

    Bitmap bmp = null ;

    public Sprite(android.content.res.Resources res,int idRess,int width, int height) {
        bmp =  BitmapFactory.decodeResource(res,idRess);
        bmp = Bitmap.createScaledBitmap(bmp, width, height, true);
    }

    public Sprite(android.content.res.Resources res,int idRess) {
        bmp =  BitmapFactory.decodeResource(res,idRess);
    }


    /**
     * En cas de bug de createScaledBitmap (constaté sans espoir, on fait un resizing manuel et moche)
     * @param newWidth
     * @param newHeight
     * @return

    public Bitmap getResizedBitmap( int newWidth , int newHeight) {

        Bitmap.Config conf = Bitmap.Config.ARGB_8888; // see other conf types
        Bitmap bmp2 = Bitmap.createBitmap(newWidth, newHeight, conf); // this creates a MUTABLE bitmap
        Canvas canvas = new Canvas(bmp2);
        Paint paint = new Paint();
        for(int i=0;i<canvas.getWidth();i++) {
            for(int j=0;j<canvas.getHeight();j++) {
                int c = bmp.getPixel((int) Math.floor(bmp.getWidth()*i/newWidth),(int) Math.floor(bmp.getHeight()*j/newHeight));
                //int c = bmp.getPixel(1,1);
                paint.setColor(c);
                canvas.drawPoint(i,j,paint);
            }
        }
        return bmp2 ;
    }
     */

}
